import sounddevice as sd
from scipy.io.wavfile import write
from scipy.io import wavfile
# print(sd.query_devices())

def record_audio(file_name):
    sd.default.device[0] = 1
    fs = 44100 # Hz
    length = 12 # s
    recording = sd.rec(frames=fs * length, samplerate=fs, blocking=True, channels=1)
    # print(len(recording))
    # for i in recording:
    #     print(i[0]*100)
    wavfile.write(file_name, fs, recording)
    
# record_audio("output1.mp3")